<?php
/**
 * Created by PhpStorm.
 * User: xiaofang
 * Date: 2020/12/12
 * Time: 14:48
 */

namespace app\api\controller;


use app\admin\model\Agateway;
use app\admin\model\NydControlDev;
use app\admin\model\NydDev;
use think\Controller;
use think\Db;
use think\Exception;

class Adapeng extends Controller
{
    /**
     * 设置设备状态
     */
    public function dev_status()
    {
        $control_id = input("dev_mac");
        $is_open = input("is_open");
        $gateway_id = input("gateway_id");

        //获取设备id
        $agw = new Agateway();
        $gw_id = $agw->gw_id($gateway_id);

        //控制单个设备
        $nycontrol = new NydControlDev();
        $res = $nycontrol->setDevStatus($gw_id,$is_open,$control_id);

        return json($res);
    }

    /**
     * dev list
     */
    public function dev_list()
    {
        $nyddev = new NydDev();
        return json(ret_com('1','success',$nyddev->get_devlist()));
    }
}